package com.whmskj.xjlhsc.mobie.equipmentManage.controller;

import com.whmskj.xjlhsc.controller.vo.Result;
import com.whmskj.xjlhsc.entity.EquipmentSpareParts;
import com.whmskj.xjlhsc.service.DevicespecificationmodelService;
import com.whmskj.xjlhsc.service.EquipmentsparepartsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张
 * @version 1.0
 */

@RestController
@RequestMapping("/mob/sbbj")
@Slf4j
@RequiredArgsConstructor
@Tag(description = "设备备件", name = "设备备件")
public class SbBjController {

    @Autowired
    private EquipmentsparepartsService equipmentsparepartsService;
    @Autowired
    private DevicespecificationmodelService devicespecificationmodelService;

    @GetMapping("sbbjList")
    @Operation(description = "设备备件集合")
    public Result sbbjList(@RequestParam(required = false)String keyWord,@RequestParam String type){
       List<EquipmentSpareParts> list = equipmentsparepartsService.sbbjList(keyWord,type);
       return Result.success(list);
    }
    @DeleteMapping("/remove/{id}")
    @Operation(description = "删除备件")
    public Result remove(@PathVariable Integer id){
        equipmentsparepartsService.removeById(id);
        return Result.success();
    }
    @PostMapping("addorUpdate")
    @Operation(description = "新增或修改")
    public Result addorUpdate(@RequestBody EquipmentSpareParts equipmentspareparts){
        equipmentsparepartsService.saveOrUpdate(equipmentspareparts);
        return Result.success();
    }
    @GetMapping("sbtype")
    @Operation(description = "设备类型")
    public Result sbtype(){
      List<String> list =  devicespecificationmodelService.sbtype();
      return Result.success(list);
    }
}
